{{- $pwa := .Scratch.Get "pwa" -}}
<script>
if ('serviceWorker' in navigator) {
    navigator.serviceWorker
        .register('/sw.min.js?version={{ $pwa.version }}', { scope: '/' })
        .then(() => {
            console.info('{{- .Site.Title -}}\u00A0Service Worker Registered');
        }, err => console.error('{{- .Site.Title -}}\u00A0Service Worker registration failed: ', err));

    navigator.serviceWorker
        .ready
        .then(() => {
            console.info('{{- .Site.Title -}}\u00A0Service Worker Ready');
        });
}
</script>
